package com.unionftech.common.webview.view

import android.os.Handler
import android.os.Message
import android.webkit.WebChromeClient
import android.webkit.WebView

class BaseWebChromeClient(private val progressHandler: Handler) : WebChromeClient() {
    override fun onProgressChanged(view: WebView?, newProgress: Int) {
        var progress = newProgress
        val message = Message.obtain()
        if (progress == 100) {
            message.obj = progress
            progressHandler.sendMessageDelayed(message, 200)
        } else {
            if (progress < 10) {
                progress = 10
            }
            message.obj = progress
            progressHandler.sendMessage(message)
        }
        super.onProgressChanged(view, progress)
    }
}
